﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GreateTool
{
    public partial class StringMergeForm : Form
    {
        public StringMergeForm()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            HashSet<string> hs1 = new HashSet<string>(richTextBox1.Lines);
            HashSet<string> hs2 = new HashSet<string>(richTextBox2.Lines);

            var arr = hs1.Where(n => hs2.Contains(n)).ToArray();

            foreach (var str in arr)
            {
                hs1.Remove(str);
                hs2.Remove(str);
            }

            richTextBox3.Lines = arr;
            richTextBox1.Lines = hs1.ToArray();
            richTextBox2.Lines = hs2.ToArray();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            richTextBox1.Text = richTextBox2.Text = richTextBox3.Text = string.Empty;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            var list = new List<string>();
            HashSet<string> hs1 = new HashSet<string>(richTextBox3.Lines);
            
            foreach (var str in richTextBox3.Lines)
            {
                if (hs1.Contains(str)) hs1.Remove(str);
                else list.Add(str);
            }

            richTextBox3.Lines = list.ToArray();
        }
    }
}
